<?php


namespace app\common\model;


class LessonType extends Base
{
    protected $autoWriteTimestamp = true;

    /**
     * 仅用于首页展示数据限制
     * @param int $status
     * @param int $limit
     * @param boolean $price 1 收费 0 免费
     * @return array $data
     */
    public function limit_lesson_msg($status,$limit,$price)
    {
        if($price) {
            $data = [
                'status' => $status
            ];
            return $this->where($data)
                        ->where('now_price','neq','0.00')
                        ->paginate($limit);
        }else{
            $data = [
                'status' => $status,
            ];
            return $this->where($data)
                        ->where('now_price','eq','0.00')
                        ->paginate($limit);
        }
    }

    /**
     * 仅用于首页展示数据限制
     * @param int $status
     * @param int $limit
     * @param boolean $price 1 收费 0 免费
     * @param boolean $top 1 首页显示 0
     * @return array $data
     */
    public function top_lesson_msg($status,$limit,$price,$top)
    {
        if($price) {
            $data = [
                'status' => $status
                ,'top'   => $top
            ];
            return $this->where($data)
                ->where('now_price','neq','0.00')
                ->paginate($limit);
        }else{
            $data = [
                'status' => $status
                ,'top'   => $top
            ];
            return $this->where($data)
                ->where('now_price','eq','0.00')
                ->paginate($limit);
        }
    }
}